home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Snippets / Testing & Debugging / Time Manager Debugging / TM.c < prev   
Encoding:
C/C++ Source or Header  |  1993-03-12  |  2.0 KB  |  101 lines  |  [TEXT/MPS ]

  1. /*     TM.c
  2.     This is the Time Manager dcmd.
  3.  
  4.     Copyright © 1988 Apple Computer, Inc.  All rights reserved.
  5.  
  6.     Modification history:
  7.          13MAR93 BRS        written from VBL.
  8.  
  9.     The following MPW commands will build the dcmd and copy it to the
  10.     "Debugger Prefs" file in the System folder. The dcmd's name in
  11.     MacsBug will be the name of the file built by the Linker.
  12.     You must first copy dcmd.h, dcmdGlue.a.o and DRunTime.o from the
  13.     C Samples folder into this folder.
  14.  
  15.     C TM.c
  16.     Link dcmdGlue.a.o TM.c.o put.c.o DRuntime.o "{Libraries}"Interface.o -o TM
  17.     BuildDcmd TM 1234
  18.     Echo 'include "TM";'    |    Rez -a -o "{systemFolder}Debugger Prefs"
  19. */
  20.  
  21. #include <Types.h>
  22. #include <OSUtils.h>
  23. #include <Timer.h>
  24.  
  25. #include "dcmd.h"
  26. #include "put.h"
  27.  
  28. #define TimeMgrQueue (TMTask*)0xB30
  29.  
  30. static void DrawHdr()
  31. {
  32. //                             1         2         3         4         5         6         7
  33. //                    1234567890123456789012345678901234567890123456789012345678901234567890
  34.     dcmdDrawLine("\p  tmAddr   tmCount  tmWakeUp   TMTask");
  35. }
  36.  
  37.  
  38. static void DrawTimeTask(TMTask* tmt)
  39. {
  40.     PutUHexZTo((unsigned long)tmt->tmAddr,8,8);
  41.     PutSpace();
  42.     PutSpace();
  43.     PutUHexZTo((unsigned long)tmt->tmCount,8,8);
  44.     PutSpace();
  45.     PutSpace();
  46.     PutUHexZTo((unsigned long)tmt->tmWakeUp,8,8);
  47.     PutSpace();
  48.     PutUHexZTo((unsigned long)tmt,8,8);
  49.     PutLine();
  50. }
  51.  
  52.  
  53. pascal void CommandEntry(dcmdBlock* paramPtr)
  54. {
  55.     switch (paramPtr->request)
  56.         {
  57.         case dcmdInit:
  58.             break;
  59.  
  60.         case dcmdHelp:
  61.             dcmdDrawLine("\pTM - Displays Time Manager Task List");
  62.             break;
  63.  
  64.         case dcmdDoIt:
  65.             {
  66.             TMTask* tmt;
  67.             int numtasks = 0;
  68.             
  69.             dcmdSwapWorlds();
  70.  
  71.             dcmdDrawLine("\pDisplaying Time Manager tasks");
  72.  
  73.             tmt = (TimeMgrQueue);
  74.             tmt = (TMTask*)(*(long*)tmt);
  75.             
  76.             DrawHdr();
  77.             while (tmt)
  78.             {
  79.                 DrawTimeTask(tmt);
  80.                 numtasks++;
  81.                 if (paramPtr->aborted) 
  82.                     break;
  83.                 tmt = (TMTask*)tmt->qLink;
  84.             }
  85.  
  86.             PutUDec(numtasks);
  87.             PutPStr("\p Time Manager tasks");
  88.             PutLine();
  89.  
  90.             dcmdSwapWorlds();
  91.             }
  92.             break;
  93.  
  94.         default:
  95.             PutPStr("\pdon't know what you mean friend! ");
  96.             PutUDec(paramPtr->request);
  97.             PutLine();
  98.             break;
  99.         }
  100. } // CommandEntry
  101.